(function() {

this.codium = this.codium || {};
this.codium.panel = this.codium.panel || {};

this.codium.panel.Menu = pasta.webgui.Panel.extend(
{
	init : function() 
	{
		this._super();
		
		this.setBgColor("rgba(0, 0, 0, 0.5)");
		this.setShadow("0px 3px 6px #000000");
		
		this.canvas.style.borderLeft = "1px solid rgba(255, 255, 255, 0.5)";
		this.canvas.style.borderRight = "1px solid rgba(255, 255, 255, 0.5)";
		
		this.logo = new pasta.webgui.Picture();
		this.logo.setTop(10);
		this.logo.setWidth(185);
		this.logo.setHeight(115);
		this.logo.setImage(this.libDir + "/img/logo.png");
		this.addControl(this.logo);
		
		this.btnOverview = new codium.control.MenuButton();
		this.btnOverview.setLeft(10);
		this.btnOverview.setTop(140);
		this.btnOverview.setCaption("Overview");
		this.btnOverview.setDescription("Project Overview");
		this.btnOverview.setIcon(this.libDir + "/img/icon/menuOverview.png");
		this.btnOverview.tag = "overview";
		this.btnOverview.getOnClick().setHandler(this, this.btnClick);
		this.addControl(this.btnOverview);
		
		this.btnMilestone = new codium.control.MenuButton();
		this.btnMilestone.setLeft(10);
		this.btnMilestone.setTop(this.btnOverview.getTop() + this.btnOverview.getHeight() + 2);
		this.btnMilestone.setCaption("Milestone");
		this.btnMilestone.setDescription("Project Milestone List");
		this.btnMilestone.setIcon(this.libDir + "/img/icon/menuMilestone.png");
		this.btnMilestone.tag = "milestone";
		this.btnMilestone.getOnClick().setHandler(this, this.btnClick);
		this.addControl(this.btnMilestone);
		
		this.btnTicket = new codium.control.MenuButton();
		this.btnTicket.setLeft(10);
		this.btnTicket.setTop(this.btnMilestone.getTop() + this.btnMilestone.getHeight() + 2);
		this.btnTicket.setCaption("Ticket");
		this.btnTicket.setDescription("Tickets List");
		this.btnTicket.setIcon(this.libDir + "/img/icon/menuTicket.png");
		this.btnTicket.tag = "ticket";
		this.btnTicket.getOnClick().setHandler(this, this.btnClick);
		this.addControl(this.btnTicket);
		
		this.btnFiles = new codium.control.MenuButton();
		this.btnFiles.setLeft(10);
		this.btnFiles.setTop(this.btnTicket.getTop() + this.btnTicket.getHeight() + 2);
		this.btnFiles.setCaption("Files");
		this.btnFiles.setDescription("Files List");
		this.btnFiles.setIcon(this.libDir + "/img/icon/menuFile.png");
		this.btnFiles.tag = "files";
		this.btnFiles.getOnClick().setHandler(this, this.btnClick);
		this.addControl(this.btnFiles);
		
		this.btnPeople = new codium.control.MenuButton();
		this.btnPeople.setLeft(10);
		this.btnPeople.setTop(this.btnFiles.getTop() + this.btnFiles.getHeight() + 2);
		this.btnPeople.setCaption("People");
		this.btnPeople.setDescription("Team MemberList");
		this.btnPeople.setIcon(this.libDir + "/img/icon/menuPeople.png");
		this.btnPeople.tag = "people";
		this.btnPeople.getOnClick().setHandler(this, this.btnClick);
		this.addControl(this.btnPeople);
		
		this.btnSetting = new codium.control.MenuButton();
		this.btnSetting.setLeft(10);
		this.btnSetting.setTop(this.btnPeople.getTop() + this.btnPeople.getHeight() + 2);
		this.btnSetting.setCaption("Setting");
		this.btnSetting.setDescription("Project Setting");
		this.btnSetting.setIcon(this.libDir + "/img/icon/menuSetting.png");
		this.btnSetting.tag = "setting";
		this.btnSetting.getOnClick().setHandler(this, this.btnClick);
		this.addControl(this.btnSetting);
		
		this.btnExit = new codium.control.MenuButton();
		this.btnExit.setLeft(10);
		this.btnExit.setTop(this.btnSetting.getTop() + this.btnSetting.getHeight() + 2);
		this.btnExit.setCaption("Keluar");
		this.btnExit.setDescription("Keluar");
		this.btnExit.setIcon(this.libDir + "/img/icon/menuExit.png");
		this.btnExit.tag = "exit";
		this.btnExit.getOnClick().setHandler(this, this.btnClick);
		this.addControl(this.btnExit);
		
		this.setWidth(230);
		
		this.selectedButton = null;
	},	
	
	btnClick : function(sender)
	{
		if (this.selectedButton != null)
			this.selectedButton.setActive(false);
		
		this.selectedButton = sender;
		
		if (this.selectedButton != null)
		{
			this.selectedButton.setActive(true);
			
			if (this._onSelect != null)
				this._onSelect.callHandler(this, sender.tag);
		}
	},
	
	//-------------------- Event Handler --------------
	
	setSelectedId : function(id)
	{
		for (var i = 0; i < this.controls.getLength(); i++)
		{
			var control = this.controls.get(i);
			
			if (control.tag == id)
			{
				this.selectedButton = control;
				
				if (this.selectedButton != null)
					this.selectedButton.setActive(true);
			}
		}
	},
	
	setWidth : function(data)
	{
		this._super(data);
		
		if (this.logo != null)
		{
			this.logo.setLeft((this.getWidth() - this.logo.getWidth()) / 2);
			this.btnOverview.setWidth(this.getWidth() - (2 * this.btnOverview.getLeft()));
			this.btnMilestone.setWidth(this.btnOverview.getWidth());
			this.btnTicket.setWidth(this.btnOverview.getWidth());
			this.btnFiles.setWidth(this.btnOverview.getWidth());
			this.btnPeople.setWidth(this.btnOverview.getWidth());
			this.btnSetting.setWidth(this.btnOverview.getWidth());
			this.btnExit.setWidth(this.btnOverview.getWidth());
		}
	},
	
	//-----------------Event Object --------------
	
	getOnSelect : function()
	{
		if (this._onSelect == null)
			this._onSelect = new pasta.util.EventObj();
		
		return this._onSelect;
	},
	
});

})();